package com.borya.dao.impl;

import org.apache.log4j.Logger;

import com.borya.dao.BlackIdCardDAO;
import com.borya.framework.annotation.Component;
import com.borya.framework.core.ServerSqlSession;

@Component("blackIdCardDAO")
public class BlackIdCardDAOImpl extends BaseDAOImpl  implements BlackIdCardDAO {

	
	private Logger log = Logger.getLogger(getClass());
	
	@Override
	public boolean idCardUsed(final String idCard) {
		try (ServerSqlSession session = getSqlDataSource().session();) {
			StringBuilder sql = new StringBuilder(256);
			sql.append("select id from tb_black_idcard ");
			sql.append(" where id_card=? limit 1");
			return session.executeQuery(sql.toString(), rs->
				 !(rs != null && rs.next())
			, idCard);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			return false;
		}
	}
	
}
